<%--
  Created by IntelliJ IDEA.
  User: 14587
  Date: 2020/11/6
  Time: 17:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="${pageContext.request.contextPath}/script/js/jquery-1.7.2.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#btn").click(function () {
                $.ajax({
                    type:"post",
                    url:"${pageContext.request.contextPath}/a2",
                    success:function (data) {
                        var html="";
                        for (let i = 0; i < data.length; i++) {
                            html+="<tr>" +
                                    "<td>"+data[i].name+"</td>"+
                                    "<td>"+data[i].age+"</td>"+
                                    "<td>"+data[i].sex+"</td>"+
                                "</tr>";
                            $("#tbody").html(html);}

                    }
                })

            })
        })
    </script>
</head>
<body>
<input type="button" value="加载数据" id="btn">
<table>
    <tr>
        <th>姓名</th>
        <th>年龄</th>
        <th>性别</th>
    </tr>
    <tbody id="tbody">
    <%--走后台展示--%>
    </tbody>
</table>
</body>
</html>
